from django.urls import re_path
from rest_framework.routers import DefaultRouter
from apps.vadmin.assets.views_check import CheckRecordsModelViewSet
from apps.vadmin.assets.views_check import ComponentsAssetsModelViewSet
from apps.vadmin.assets.views_check import LicenceRecordsModelViewSet
from apps.vadmin.assets.views_check import AccessoryRecordsModelViewSet
from apps.vadmin.assets.views_check import ConsumableRecordsModelViewSet
from apps.vadmin.assets.views_check import AssetNowCheckoutModelViewSet

from apps.vadmin.assets.views import CategoriesModelViewSet, \
        DepreciationsModelViewSet, MaintenancesModelViewSet, \
        SuppliersModelViewSet, \
        ManufacturersModelViewSet,\
        AssetsModelViewSet,\
        AccessoriesModelViewSet,\
        ComponentsModelViewSet,\
        ConsumablesModelViewSet,\
        LicensesModelViewSet,\
        KitsModelViewSet, UploadsModelViewSet,\
        UserCheckoutReportModelViewSet,ReportViewSet,CategoryTotalReportModelViewSet,\
        LocationsModelViewSet
        

from apps.vadmin.assets.views import ModelsModelViewSet


router = DefaultRouter()
router.register(r'categories', CategoriesModelViewSet)
router.register(r'models', ModelsModelViewSet)
router.register(r'suppliers', SuppliersModelViewSet)
router.register(r'manufacturers', ManufacturersModelViewSet)
router.register(r'depreciations', DepreciationsModelViewSet)
router.register(r'assets', AssetsModelViewSet)
router.register(r'accessories', AccessoriesModelViewSet)
router.register(r'components', ComponentsModelViewSet)
router.register(r'consumables', ConsumablesModelViewSet)
router.register(r'licenses', LicensesModelViewSet)
router.register(r'kits', KitsModelViewSet)
router.register(r'maintenances', MaintenancesModelViewSet)
router.register(r'uploads', UploadsModelViewSet)
router.register(r'locations', LocationsModelViewSet)

'''
DefaultRouter 默认的路由器自动实现下面的路由
例如
/categories/                - GET 查询所有
/categories/                - post 新增类别
/categories/{id}/ GET       - 显示单个类别
/categories/{id}/ PUT       - 编辑单个类别
/categories/{id}/ DELETE    - 删除单个类别
'''


urlpatterns = [
    re_path('^locations/export/', LocationsModelViewSet.as_view({'get': 'export'})),
    re_path('^locations/import/', LocationsModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^depreciations/export/', DepreciationsModelViewSet.as_view({'get': 'export'})),
    re_path('^depreciations/import/', DepreciationsModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^categories/export/', CategoriesModelViewSet.as_view({'get': 'export'})),
    re_path('^categories/import/', CategoriesModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^models/export/', ModelsModelViewSet.as_view({'get': 'export'})),
    re_path('^models/import/', ModelsModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^suppliers/export/', SuppliersModelViewSet.as_view({'get': 'export'})),
    re_path('^suppliers/import/', SuppliersModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^manufacturers/export/', ManufacturersModelViewSet.as_view({'get': 'export'})),
    re_path('^manufacturers/import/', ManufacturersModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^assets/export/', AssetsModelViewSet.as_view({'get': 'export'})),
    re_path('^assets/import/', AssetsModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^accessories/export/', AccessoriesModelViewSet.as_view({'get': 'export'})),
    re_path('^accessories/import/', AccessoriesModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^components/export/', ComponentsModelViewSet.as_view({'get': 'export'})),
    re_path('^components/import/', ComponentsModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^consumables/export/', ConsumablesModelViewSet.as_view({'get': 'export'})),
    re_path('^consumables/import/', ConsumablesModelViewSet.as_view({'post': 'importTemplate'})),

    re_path('^licenses/export/', LicensesModelViewSet.as_view({'get': 'export'})),
    re_path('^licenses/import/', LicensesModelViewSet.as_view({'post': 'importTemplate'})),

    re_path(r'^kits/addassets/', KitsModelViewSet.as_view({'post': 'add_assets'})),
    re_path(r'^kits/getassets/', KitsModelViewSet.as_view({'get': 'get_assets'})),
    re_path(r'^kits/delassets/', KitsModelViewSet.as_view({'delete': 'del_assets'})),

    re_path(r'^componentrecords/', ComponentsAssetsModelViewSet.as_view({'get': 'list'})),       # 资产组件记录
    re_path(r'^licenserecords/', LicenceRecordsModelViewSet.as_view({'get': 'list'})),           # license记录
    re_path(r'^accessoryrecords/', AccessoryRecordsModelViewSet.as_view({'get': 'list'})),       # 附属品记录
    re_path(r'^consumablerecords/', ConsumableRecordsModelViewSet.as_view({'get': 'list'})),     # 消耗品记录

    re_path(r'^audit/', CheckRecordsModelViewSet.as_view({'post': 'asset_audit'})),           # 审核
    re_path(r'^batchcheckout/', CheckRecordsModelViewSet.as_view({'post': 'asset_batch_checkout'})),# 批量借出
    re_path(r'^kitscheckout/', CheckRecordsModelViewSet.as_view({'post': 'kits_checkout'})),        # 套件借出
    re_path(r'^checkout/', CheckRecordsModelViewSet.as_view({'post': 'checkout'})),                 # 借出
    re_path(r'^assignedinfo/', AssetNowCheckoutModelViewSet.as_view({'get': 'list'})),              # 当前借出情况
    re_path(r'^checkin/', CheckRecordsModelViewSet.as_view({'post': 'checkin'})),                   # 归还,支持批量
    re_path(r'^checkhis/', CheckRecordsModelViewSet.as_view({'get': 'list'})),          # 借出历史记录


    #以下是报表相关
    re_path(r'^usercheckoutreport/', UserCheckoutReportModelViewSet.as_view({'get': 'list'})),       
    re_path(r'^categorytotalreport/', CategoryTotalReportModelViewSet.as_view({'get': 'list'})),       
    re_path(r'^totalreport/', ReportViewSet.as_view({'get': 'total'})),       
    re_path(r'^assetstatusreport/', ReportViewSet.as_view({'get': 'assetStatus'})),       
]
urlpatterns += router.urls
